package day19;

import java.io.IOException;
import java.io.InputStream;

/**
 * 需求：获取键盘录入
 * 通过键盘录入数据
 * 当录入一行数据后，就将该行数据进行打印
 * 如果录入的数据是over，那么就停止录入
 * 
 * @author wangbiao
 *
 */
public class ReadIn {

	public static void main(String[] args) {
		InputStream in = System.in;
		StringBuffer sb = new StringBuffer(16*2);
		while (true) {
			try {
				int b = in.read();
				if (b == '\r') {
					continue;
				}
				if (b == '\n') {
					String buf = sb.toString();
					if ("over".equals(buf)) {
						break;
					}
					System.out.println(buf.toUpperCase());
					sb.delete(0, sb.length());
				} 
				sb.append((char)b);
			} catch (IOException e) {
				throw new RuntimeException("标准输入流输入失败！");
			} finally {
				if (null != in) {
					try {
						in.close();
					} catch (IOException e) {
						throw new RuntimeException("标准输入流关闭失败！");
					}
				}
			}
			
		}
	}
}
